using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations.Schema;
using SalesPages.DomainModel;

namespace SalesPages.EntityFrameworkRepository.Mapping
{
    public class PromotionMap : EntityTypeConfiguration<Promotion>
    {
        public PromotionMap()
        {
            // Primary Key
            this.HasKey(t => t.PromoId);

            // Properties
            this.Property(t => t.PromoId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.PromoName)
                .IsRequired()
                .HasMaxLength(200);

            this.Property(t => t.Locale)
                .HasMaxLength(50);

            this.Property(t => t.SchoolName)
                .HasMaxLength(50);

            this.Property(t => t.Type)
                .HasMaxLength(50);

            this.Property(t => t.SiteVersion)
                .HasMaxLength(20);

            // Table & Column Mappings
            this.ToTable("Promotions");
            this.Property(t => t.PromoId).HasColumnName("PromoId");
            this.Property(t => t.PromoName).HasColumnName("PromoName");
            this.Property(t => t.Locale).HasColumnName("Locale");
            this.Property(t => t.SchoolName).HasColumnName("SchoolName");
            this.Property(t => t.Type).HasColumnName("Type");
            this.Property(t => t.SchoolTab).HasColumnName("SchoolTab");
            this.Property(t => t.AdultTab).HasColumnName("AdultTab");
            this.Property(t => t.TeenTab).HasColumnName("TeenTab");
            this.Property(t => t.KidTab).HasColumnName("KidTab");
            this.Property(t => t.Priority).HasColumnName("Priority");
            this.Property(t => t.StartDate).HasColumnName("StartDate");
            this.Property(t => t.EndDate).HasColumnName("EndDate");
            this.Property(t => t.ShowPromoLive).HasColumnName("ShowPromoLive");
            this.Property(t => t.SiteVersion).HasColumnName("SiteVersion");
        }
    }
}
